package view.controller;

import common.NowUser;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseEvent;
import javafx.stage.Stage;
import view.ChangeGroupInfo;

import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;

public class GroupInformationOwnerController implements Initializable {
    public TextArea groupintroduction;
    public Label grid;
    public Label grname;
    public Label groupid;
    public Label groupname;
    public Label ownerid;
    public Label ownername;
    public Label changegrct;
    public ImageView ownerimg;
    public ImageView img;

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        groupintroduction.setEditable(false);
        groupintroduction.setWrapText(true);
        groupintroduction.setText(NowUser.group.getGroupsign());
        groupid.setText(NowUser.group.getGroupid());
        grid.setText(NowUser.group.getGroupid());
        groupname.setText(NowUser.group.getGroupname());
        grname.setText(NowUser.group.getGroupname());
        ownerid.setText(NowUser.group.getOwnerid());
        ownername.setText(NowUser.group.getOwnername());
        if(NowUser.group.getOwnerheadimage()!=null && !NowUser.group.getOwnerheadimage().equals("")&&!NowUser.group.getOwnerheadimage().equals("null")){
            // System.out.println(user.getPhoto());
            Image image=new Image("file:" + NowUser.group.getOwnerheadimage());
            ownerimg.setImage(image);
        }else{
            Image image=new Image("view/photo/默认头像.jpg");
            ownerimg.setImage(image);
        }
        if(NowUser.group.getGroupheadimage()!=null && !NowUser.group.getGroupheadimage().equals("")&&!NowUser.group.getGroupheadimage().equals("null")){
            // System.out.println(user.getPhoto());
            Image image=new Image("file:" + NowUser.group.getGroupheadimage());
            img.setImage(image);
        }else{
            Image image=new Image("view\\photo\\群头像.jpg");
            img.setImage(image);
        }
    }

    public void tochange(MouseEvent mouseEvent) throws IOException {
        Stage stage = (Stage) changegrct.getScene().getWindow();
        stage.close();
        ChangeGroupInfo rj=new ChangeGroupInfo();
        Stage newstage = new Stage();
        rj.start(newstage);
    }
}
